package com.example.curriculum.controller;

import com.example.curriculum.pojo.Business;
import com.example.curriculum.pojo.ResponseMessage;
import com.example.curriculum.service.BusinessService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Business")
public class BusinessController {
    @Resource
    private BusinessService businessService;

    @PostMapping
    public ResponseMessage<Business> add(@Validated  @RequestBody Business business){
        Business newbusiness = businessService.add(business);
        return ResponseMessage.success(newbusiness);
    }
    @GetMapping("/{biz_id}")
    public ResponseMessage<Business> select(@PathVariable String biz_id){
        Business business = businessService.select(biz_id);
        return ResponseMessage.success(business);
    }
    @PutMapping
    public ResponseMessage<Business> update(@Validated  @RequestBody Business business){
        Business newbusiness = businessService.update(business);
        return ResponseMessage.success(newbusiness);
    }
    @DeleteMapping("/{biz_id}")
    public ResponseMessage<Business> delete(@PathVariable String biz_id){
        businessService.delete(biz_id);
        return ResponseMessage.success();
    }
}
